# Maintainer: Felix Yan <felixonmars@archlinux.org>

_hkgname=attoparsec-iso8601
pkgname=haskell-attoparsec-iso8601
pkgver=1.1.0.0
pkgrel=41
pkgdesc="Parsing of ISO 8601 dates, originally from aeson"
url="https://github.com/haskell/aeson"
license=('BSD')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-attoparsec' 'haskell-base-compat-batteries' 'haskell-time-compat')
makedepends=('ghc' 'uusi')
source=("https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz")
sha512sums=('4613c2e1b492c4ebf30d1788e8b067592e507e226bd85caacc1844d5a486c1b9c8727117e426763122836205b7341b8603ac15566facd3f0338b55e784f4dfe0')

prepare() {
    cd $_hkgname-$pkgver
    gen-setup
}

build() {
    cd $_hkgname-$pkgver

    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
            -f-developer -f-fast
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver

    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
